const benchmark = require('benchmark')
const {parseControlParameters} = require("./CommandBase");
const {createIdentifierByString} = require("../component/Identifier");
const {ControlParameters} = require("../component/ControlParameters");
const {createCommandIdentifierInterest} = require("./CommandBase");

let parameters = new ControlParameters()
let prefix = createIdentifierByString("/pku/sz")
parameters.ControlParameterPrefix.setPrefix(prefix)
parameters.ControlParameterLogicFaceId.setLogicFaceId(1)
parameters.ControlParameterCost.setCost(1)
parameters.ControlParameterCapacity.setCapacity(1)
parameters.ControlParameterCount.setCount(1)
parameters.ControlParameterExpireTime.setExpireTime(1)
parameters.ControlParameterUri.setUri("/pku/sz")
parameters.ControlParameterLocalUri.setLocalUri("/local")
parameters.ControlParameterLogicFacePersistency.setPersistency(1)
parameters.ControlParameterUriScheme.setUriScheme(1)
parameters.ControlParameterMtu.setMtu(1)

const suite1 = new benchmark.Suite()
suite1.add('createCommandIdentifierInterest', ()=>{
    createCommandIdentifierInterest(parameters, "/cp1/test")
}).on('cycle', (event) => {
    console.log(String(event.target))
}).on('complete', () =>{
    console.log('createCommandIdentifierInterest finished')
}).run()

let interest = createCommandIdentifierInterest(parameters, "/cp1/test")
const suite2 = new benchmark.Suite()
suite2.add('parseCommandFromInterest', ()=>{
    parseControlParameters(interest)
}).on('cycle', (event) => {
    console.log(String(event.target))
}).on('complete', () =>{
    console.log('parseCommandFromInterest finished')
}).run()
